import akshare as ak  # type: ignore
import pandas as pd

from ..cache import cache
from .base import IndexDataProvider


class EastmoneyInfo(IndexDataProvider):
    @cache(
        "index_cache",
        key=lambda self: "eastmoney_index_stock_info",
    )
    def get_index_stock_info(self) -> pd.DataFrame:
        """获取股票指数信息一览表"""
        info_df = ak.index_stock_info()
        return info_df
    
    def get_index_stock_cons_weight(self, symbol: str) -> pd.DataFrame:
        """获取中证指数成份股权重"""
        weight_df = ak.index_stock_cons_weight_csindex(symbol=symbol)
        return weight_df
